package com.learning.code.multithread.keyword.synchronize.method.sychronizedObject;

public class MyObject {

    synchronized public void methodA(){
        try {
            System.out.println("methodA is begining,current thread is " +Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("methodA is end,current thread is " +Thread.currentThread().getName());

        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public void methodB(){
        try {
            System.out.println("methodB is begining,current thread is " +Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("methodB is end,current thread is " +Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
    synchronized public void methodC(){
        try {
            System.out.println("methodC is begining,current thread is " +Thread.currentThread().getName());
            Thread.sleep(5000);
            System.out.println("methodC is end,current thread is " +Thread.currentThread().getName());
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
